summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/nvnflinger/hos_binder_driver_server.cpp
blob: b86a79ec9350a873b13eae6a8c4101bb2c1b7ad3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later

#include <mutex>

#include "common/common_types.h"
#include "core/hle/service/nvnflinger/hos_binder_driver_server.h"

namespace Service::Nvnflinger {

HosBinderDriverServer::HosBinderDriverServer(Core::System& system_)
    : service_context(system_, "HosBinderDriverServer") {}

HosBinderDriverServer::~HosBinderDriverServer() {}

u64 HosBinderDriverServer::RegisterProducer(std::unique_ptr<android::IBinder>&& binder) {
    std::scoped_lock lk{lock};

    last_id++;

    producers[last_id] = std::move(binder);

    return last_id;
}

android::IBinder* HosBinderDriverServer::TryGetProducer(u64 id) {
    std::scoped_lock lk{lock};

    if (auto search = producers.find(id); search != producers.end()) {
        return search->second.get();
    }

    return {};
}

} // namespace Service::Nvnflinger